package com.spring.appconfig.example;

import com.spring.appconfig.example.config.UserConfig;
import com.spring.appconfig.example.pojo.User;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class test {
    @Test
    public void test(){
        //如果完全使用了配置类方式去做,我们就只能通过AnnotationConfig上下文来获取容器,铜锅配置类的class对象加载
        ApplicationContext context = new AnnotationConfigApplicationContext(UserConfig.class);
        User user = context.getBean("getUser", User.class); //取的是方法名
        System.out.println(user.getName());
    }
}
